public class BinarySearch {

	public static void main(String[] args) {
		int list[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
		int key = 1;
		System.out.println(binarySearch(list, key, 0, list.length - 1));

	}

	public static int binarySearch(int[] list, int key, int low, int high) {
		if (low > high) {
			return -1;
		}
		int mid = (low + high) / 2;
		if (key < list[mid]) {
			return binarySearch(list, key, low, mid - 1);
		} else if (key > list[mid]) {
			return binarySearch(list, key, mid + 1, high);
		} else {
			return mid;
		}

	}
}
